package com.codechenxi.study.config;

import com.codechenxi.study.service.ChatAssistant;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author codechenxi
 * @description
 * @since 2025-07-02 21:56
 */
@Configuration
public class LLMConfig {


    /**
     * @description 知识出处 https://docs.langchain4j.dev/get-started
     * @return
     */

    @Bean(name="qwen")
    public ChatModel chatModelQwen() {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .modelName("qwen-plus")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    @Bean(name="deepseek")
    public ChatModel chatModelDeepSeek() {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("DEEPSEEK_API_KEY"))
//                .modelName("deepseek-chat")
              .modelName("deepseek-reasoner")
                .baseUrl("https://api.deepseek.com/v1")
                .build();
    }

    // High-Api https://docs.langchain4j.dev/tutorials/ai-services#simplest-ai-service
    @Bean
    public ChatAssistant chatAssistant(@Qualifier("qwen") ChatModel chatModelQwen){
        return AiServices.create(ChatAssistant.class,chatModelQwen);
    }
}
